<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('生成激活码')"/>
    <th:block th:include="include :: datetimepicker-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-code-add">
        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label is-required">激活码类型：</label>
                <div class="col-sm-8">
                    <select name="type" class="form-control">
                        <option value="1">月卡</option>
                        <option value="2">季卡</option>
                        <option value="3" selected="selected">年卡</option>
                        <option value="0">永久</option>
                    </select>

                </div>
            </div>
        </div>

        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">是否上传发卡平台：</label>
                <div class="col-sm-8">
                    <select name="isUp" class="form-control" th:with="type=${@dict.getType('biz_code_up_status')}">
                        <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                th:value="${dict.dictValue}"></option>
                    </select>
                </div>
            </div>
        </div>

        <div class="col-xs-12">
            <div class="form-group">
                <label class="col-sm-3 control-label">生成数量：</label>
                <div class="col-sm-8">
                    <select name="num" class="form-control">
                        <option value="50" selected="selected">50个</option>
                        <option value="100">100个</option>
                        <option value="300">300个</option>
                        <option value="1000">1000个</option>
                    </select>
                </div>
            </div>
        </div>


    </form>

    <div class="col-xs-12" style="align-content: center">
        <button class="btn btn-primary" onclick="submitHandler()">立即生成</button>

        <a class="btn btn-danger" th:href="@{/biz/code}">返回</a>
    </div>

    <div class="col-xs-12" style="margin: 5px">
        <div class="alert alert-danger">
            <a class="alert-link" href="javascript:;">注意！！！：</a>如果选择已上传, 则需要及时把下面的激活码上架到发卡平台,
            不然后续统计比较困难! 合理顺序: 是批量生成选择已上传, 上传到发卡平台, 结束!
        </div>
    </div>

    <ol id="codeOl">

    </ol>


</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var prefix = ctx + "biz/code"
    $("#form-code-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/generate", $('#form-code-add').serialize(), function (resp) {
                // console.log(resp);
                // console.log(resp.data);
                if (resp.data.length > 0) {
                    for (let i = 0; i < resp.data.length; i++) {
                        $('#codeOl').append('<li>' + resp.data[i] + '</li>');
                    }

                }
            });


        }
    }
</script>
</body>
</html>